Optimal. Leaf size=132 \[ \frac {i a^2 (B+(i A+B) (2+m)) \tan ^{1+m}(c+d x)}{d (1+m) (2+m)}+\frac {2 a^2 (A-i B) \, _2F_1(1,1+m;2+m;i \tan (c+d x)) \tan ^{1+m}(c+d x)}{d (1+m)}+\frac {i B \tan ^{1+m}(c+d x) \left (a^2+i a^2 \tan (c+d x)\right )}{d (2+m)} \]
[Out]
________________________________________________________________________________________
Rubi [A]
time = 0.26, antiderivative size = 132, normalized size of antiderivative = 1.00, number of steps
used = 5, number of rules used = 5, integrand size = 34, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.147, Rules used = {3675, 3673,
3618, 12, 66} \begin {gather*} \frac {2 a^2 (A-i B) \tan ^{m+1}(c+d x) \, _2F_1(1,m+1;m+2;i \tan (c+d x))}{d (m+1)}+\frac {i a^2 (B+(m+2) (B+i A)) \tan ^{m+1}(c+d x)}{d (m+1) (m+2)}+\frac {i B \left (a^2+i a^2 \tan (c+d x)\right ) \tan ^{m+1}(c+d x)}{d (m+2)} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
Rule 12
Rule 66
Rule 3618
Rule 3673
Rule 3675
Rubi steps
\begin {align*} \int \tan ^m(c+d x) (a+i a \tan (c+d x))^2 (A+B \tan (c+d x)) \, dx &=\frac {i B \tan ^{1+m}(c+d x) \left (a^2+i a^2 \tan (c+d x)\right )}{d (2+m)}+\frac {\int \tan ^m(c+d x) (a+i a \tan (c+d x)) (-a (i B (1+m)-A (2+m))+a (B+(i A+B) (2+m)) \tan (c+d x)) \, dx}{2+m}\\ &=\frac {i a^2 (B+(i A+B) (2+m)) \tan ^{1+m}(c+d x)}{d (1+m) (2+m)}+\frac {i B \tan ^{1+m}(c+d x) \left (a^2+i a^2 \tan (c+d x)\right )}{d (2+m)}+\frac {\int \tan ^m(c+d x) \left (2 a^2 (A-i B) (2+m)+2 a^2 (i A+B) (2+m) \tan (c+d x)\right ) \, dx}{2+m}\\ &=\frac {i a^2 (B+(i A+B) (2+m)) \tan ^{1+m}(c+d x)}{d (1+m) (2+m)}+\frac {i B \tan ^{1+m}(c+d x) \left (a^2+i a^2 \tan (c+d x)\right )}{d (2+m)}+\frac {\left (4 i a^4 (A-i B)^2 (2+m)\right ) \text {Subst}\left (\int \frac {2^{-m} \left (\frac {x}{a^2 (i A+B) (2+m)}\right )^m}{4 a^4 (i A+B)^2 (2+m)^2+2 a^2 (A-i B) (2+m) x} \, dx,x,2 a^2 (i A+B) (2+m) \tan (c+d x)\right )}{d}\\ &=\frac {i a^2 (B+(i A+B) (2+m)) \tan ^{1+m}(c+d x)}{d (1+m) (2+m)}+\frac {i B \tan ^{1+m}(c+d x) \left (a^2+i a^2 \tan (c+d x)\right )}{d (2+m)}+\frac {\left (i 2^{2-m} a^4 (A-i B)^2 (2+m)\right ) \text {Subst}\left (\int \frac {\left (\frac {x}{a^2 (i A+B) (2+m)}\right )^m}{4 a^4 (i A+B)^2 (2+m)^2+2 a^2 (A-i B) (2+m) x} \, dx,x,2 a^2 (i A+B) (2+m) \tan (c+d x)\right )}{d}\\ &=\frac {i a^2 (B+(i A+B) (2+m)) \tan ^{1+m}(c+d x)}{d (1+m) (2+m)}+\frac {2 a^2 (A-i B) \, _2F_1(1,1+m;2+m;i \tan (c+d x)) \tan ^{1+m}(c+d x)}{d (1+m)}+\frac {i B \tan ^{1+m}(c+d x) \left (a^2+i a^2 \tan (c+d x)\right )}{d (2+m)}\\ \end {align*}
________________________________________________________________________________________
Mathematica [B] Both result and optimal contain complex but leaf count is larger than twice
the leaf count of optimal. \(1587\) vs. \(2(132)=264\).
time = 8.14, size = 1587, normalized size = 12.02 \begin {gather*} \frac {i 2^{-m} A \left (-\frac {i \left (-1+e^{2 i (c+d x)}\right )}{1+e^{2 i (c+d x)}}\right )^m \cos ^3(c+d x) \left (2^m \, _2F_1\left (1,m;1+m;-\frac {-1+e^{2 i (c+d x)}}{1+e^{2 i (c+d x)}}\right )-\left (1+e^{2 i (c+d x)}\right )^m \, _2F_1\left (m,m;1+m;\frac {1}{2} \left (1-e^{2 i (c+d x)}\right )\right )\right ) (a+i a \tan (c+d x))^2 (A+B \tan (c+d x))}{d m (\cos (d x)+i \sin (d x))^2 (A \cos (c+d x)+B \sin (c+d x))}+\frac {2^{-m} B \left (-\frac {i \left (-1+e^{2 i (c+d x)}\right )}{1+e^{2 i (c+d x)}}\right )^m \cos ^3(c+d x) \left (2^m \, _2F_1\left (1,m;1+m;-\frac {-1+e^{2 i (c+d x)}}{1+e^{2 i (c+d x)}}\right )-\left (1+e^{2 i (c+d x)}\right )^m \, _2F_1\left (m,m;1+m;\frac {1}{2} \left (1-e^{2 i (c+d x)}\right )\right )\right ) (a+i a \tan (c+d x))^2 (A+B \tan (c+d x))}{d m (\cos (d x)+i \sin (d x))^2 (A \cos (c+d x)+B \sin (c+d x))}-\frac {2 i (A-i B) e^{-2 i c} \left (-1+e^{2 i (c+d x)}\right )^m \left (-\frac {i \left (-1+e^{2 i (c+d x)}\right )}{1+e^{2 i (c+d x)}}\right )^m \left (\frac {-1+e^{2 i (c+d x)}}{1+e^{2 i (c+d x)}}\right )^{-m} \cos ^3(c+d x) \left (-\frac {\left (1+e^{2 i (c+d x)}\right )^{-m} \, _2F_1\left (1,m;1+m;\frac {1-e^{2 i (c+d x)}}{1+e^{2 i (c+d x)}}\right )}{m}-\frac {\left (1+e^{2 i c}\right ) \left (-1+e^{2 i (c+d x)}\right ) \left (1+e^{2 i (c+d x)}\right )^{-1-m} \, _2F_1\left (1,1+m;2+m;\frac {1-e^{2 i (c+d x)}}{1+e^{2 i (c+d x)}}\right )}{1+m}+\frac {2^{-m} \, _2F_1\left (m,m;1+m;\frac {1}{2} \left (1-e^{2 i (c+d x)}\right )\right )}{m}\right ) (a+i a \tan (c+d x))^2 (A+B \tan (c+d x))}{d \left (1+e^{2 i c}\right ) (\cos (d x)+i \sin (d x))^2 (A \cos (c+d x)+B \sin (c+d x))}+\frac {2^{-m} A \left (-\frac {i \left (-1+e^{2 i (c+d x)}\right )}{1+e^{2 i (c+d x)}}\right )^m \cos ^3(c+d x) \left (2^m \, _2F_1\left (1,m;1+m;-\frac {-1+e^{2 i (c+d x)}}{1+e^{2 i (c+d x)}}\right )-\left (1+e^{2 i (c+d x)}\right )^m \, _2F_1\left (m,m;1+m;\frac {1}{2} \left (1-e^{2 i (c+d x)}\right )\right )\right ) \tan (c) (a+i a \tan (c+d x))^2 (A+B \tan (c+d x))}{d m (\cos (d x)+i \sin (d x))^2 (A \cos (c+d x)+B \sin (c+d x))}-\frac {i 2^{-m} B \left (-\frac {i \left (-1+e^{2 i (c+d x)}\right )}{1+e^{2 i (c+d x)}}\right )^m \cos ^3(c+d x) \left (2^m \, _2F_1\left (1,m;1+m;-\frac {-1+e^{2 i (c+d x)}}{1+e^{2 i (c+d x)}}\right )-\left (1+e^{2 i (c+d x)}\right )^m \, _2F_1\left (m,m;1+m;\frac {1}{2} \left (1-e^{2 i (c+d x)}\right )\right )\right ) \tan (c) (a+i a \tan (c+d x))^2 (A+B \tan (c+d x))}{d m (\cos (d x)+i \sin (d x))^2 (A \cos (c+d x)+B \sin (c+d x))}+\frac {\cos ^3(c+d x) \left (\frac {(B \cos (c-d x)-B \cos (c+d x)) \sec ^2(c) \sec (c+d x) \left (\frac {1}{2} \cos (2 c)-\frac {1}{2} i \sin (2 c)\right )}{1+m}+\frac {(-3-2 m+\cos (2 c)) \sec ^2(c) \left (-\frac {1}{2} B \cos (2 c)+\frac {1}{2} i B \sin (2 c)\right )}{(1+m) (2+m)}+\frac {\sec ^2(c+d x) (-B \cos (2 c)+i B \sin (2 c))}{2+m}\right ) \tan ^m(c+d x) (a+i a \tan (c+d x))^2 (A+B \tan (c+d x))}{d (\cos (d x)+i \sin (d x))^2 (A \cos (c+d x)+B \sin (c+d x))}+\frac {\cos ^3(c+d x) \left (\frac {\sec ^2(c) \sec (c+d x) \left (\frac {1}{2} \cos (2 c)-\frac {1}{2} i \sin (2 c)\right ) (-B \cos (c-d x)+B \cos (c+d x)+A \sin (c-d x)-2 i B \sin (c-d x)-A \sin (c+d x)+2 i B \sin (c+d x))}{1+m}+\frac {\sec (c) (A \cos (c)-2 i B \cos (c)+B \sin (c)) (-\cos (2 c)+i \sin (2 c)) \tan (c)}{1+m}\right ) \tan ^m(c+d x) (a+i a \tan (c+d x))^2 (A+B \tan (c+d x))}{d (\cos (d x)+i \sin (d x))^2 (A \cos (c+d x)+B \sin (c+d x))} \end {gather*}
Warning: Unable to verify antiderivative.
[In]
[Out]
________________________________________________________________________________________
Maple [F]
time = 0.33, size = 0, normalized size = 0.00 \[\int \left (\tan ^{m}\left (d x +c \right )\right ) \left (a +i a \tan \left (d x +c \right )\right )^{2} \left (A +B \tan \left (d x +c \right )\right )\, dx\]
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Maxima [F]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \text {Failed to integrate} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Fricas [F]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \text {could not integrate} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Sympy [F]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} - a^{2} \left (\int \left (- A \tan ^{m}{\left (c + d x \right )}\right )\, dx + \int A \tan ^{2}{\left (c + d x \right )} \tan ^{m}{\left (c + d x \right )}\, dx + \int \left (- B \tan {\left (c + d x \right )} \tan ^{m}{\left (c + d x \right )}\right )\, dx + \int B \tan ^{3}{\left (c + d x \right )} \tan ^{m}{\left (c + d x \right )}\, dx + \int \left (- 2 i A \tan {\left (c + d x \right )} \tan ^{m}{\left (c + d x \right )}\right )\, dx + \int \left (- 2 i B \tan ^{2}{\left (c + d x \right )} \tan ^{m}{\left (c + d x \right )}\right )\, dx\right ) \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Giac [F]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \text {could not integrate} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Mupad [F]
time = 0.00, size = -1, normalized size = -0.01 \begin {gather*} \int {\mathrm {tan}\left (c+d\,x\right )}^m\,\left (A+B\,\mathrm {tan}\left (c+d\,x\right )\right )\,{\left (a+a\,\mathrm {tan}\left (c+d\,x\right )\,1{}\mathrm {i}\right )}^2 \,d x \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________